package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.BusinessUnitAndEssUnit;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.IBusinessUnitAndEssUnitService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务系统单位id与签章系统单位id对照Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/businUnitAndEssUnit")
public class BusinessUnitAndEssUnitController extends BaseController
{
    @Autowired
    private IBusinessUnitAndEssUnitService businessUnitAndEssUnitService;

    /**
     * 查询业务系统单位id与签章系统单位id对照列表
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessUnitAndEssUnit businessUnitAndEssUnit)
    {
        startPage();
        List<BusinessUnitAndEssUnit> list = businessUnitAndEssUnitService.selectBusinessUnitAndEssUnitList(businessUnitAndEssUnit);
        return getDataTable(list);
    }

    /**
     * 导出业务系统单位id与签章系统单位id对照列表
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:export')")
    @Log(title = "业务系统单位id与签章系统单位id对照", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusinessUnitAndEssUnit businessUnitAndEssUnit)
    {
        List<BusinessUnitAndEssUnit> list = businessUnitAndEssUnitService.selectBusinessUnitAndEssUnitList(businessUnitAndEssUnit);
        ExcelUtil<BusinessUnitAndEssUnit> util = new ExcelUtil<BusinessUnitAndEssUnit>(BusinessUnitAndEssUnit.class);
        return util.exportExcel(list, "业务系统单位id与签章系统单位id对照数据");
    }

    /**
     * 获取业务系统单位id与签章系统单位id对照详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(businessUnitAndEssUnitService.selectBusinessUnitAndEssUnitById(id));
    }

    /**
     * 新增业务系统单位id与签章系统单位id对照
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:add')")
    @Log(title = "业务系统单位id与签章系统单位id对照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessUnitAndEssUnit businessUnitAndEssUnit)
    {
        return toAjax(businessUnitAndEssUnitService.insertBusinessUnitAndEssUnit(businessUnitAndEssUnit));
    }

    /**
     * 修改业务系统单位id与签章系统单位id对照
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:edit')")
    @Log(title = "业务系统单位id与签章系统单位id对照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessUnitAndEssUnit businessUnitAndEssUnit)
    {
        return toAjax(businessUnitAndEssUnitService.updateBusinessUnitAndEssUnit(businessUnitAndEssUnit));
    }

    /**
     * 删除业务系统单位id与签章系统单位id对照
     */
    @PreAuthorize("@ss.hasPermi('system:businUnitAndEssUnit:remove')")
    @Log(title = "业务系统单位id与签章系统单位id对照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessUnitAndEssUnitService.deleteBusinessUnitAndEssUnitByIds(ids));
    }
}
